package a66weding.com.jiehuntong.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.adapter.NameRemarkAdapter;

/**
 * Created by admin on 2016/7/25.
 */
public class NameRemarkActivity extends Activity implements AdapterView.OnItemClickListener{
    private ListView lv;
    private List<String> list = new ArrayList<>();
    private NameRemarkAdapter  nameRemarkAdapter ;
    private TextView title_tv;
    private TextView back_iamge;
    private EditText editText;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_nameremark);
        initView();
        initData();
    }
    private void initView(){
        lv = (ListView) findViewById(R.id.lv);
        title_tv = (TextView) findViewById(R.id.title_tv);
        title_tv.setText("添加备注");
        back_iamge = (TextView) findViewById(R.id.back_iamge);
        back_iamge.setText("我的朋友");
        editText = (EditText) findViewById(R.id.lv_editext);
    }
    private void initData(){
        list.add("爸爸");
        list.add("妈妈");
        list.add("爷爷");
        list.add("奶奶");
        list.add("叔叔");
        list.add("阿姨");
        list.add("姑姑");
        list.add("舅舅");
        nameRemarkAdapter = new NameRemarkAdapter(this,list);
        lv.setAdapter(nameRemarkAdapter);
        lv.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        editText.setText(list.get(position));
    }
    public void back(View view){
        //获得内容
        String result = editText.getText().toString();
        Intent intent = new Intent();
        intent.putExtra("Flag",result);
        setResult(1,intent);
        finish();
    }


}
